#ifndef __NONAME_INLINE_HOOK_H__
#define __NONAME_INLINE_HOOK_H__

#define NONAME_LIB_USE

#include <ntifs.h>
#include "nm_mem.h"
#include "disasm/LDasm.h"

typedef BOOLEAN (__stdcall *HOOKPROC)(PVOID Context);

typedef struct _DPCLOCK_CONTEXT {

	PKDPC Dpcs;
	LONG Locks;
	BOOLEAN Release;

	_DPCLOCK_CONTEXT() : Dpcs(NULL), Locks(0), Release(FALSE) {}

} DPCLOCK_CONTEXT, *PDPCLOCK_CONTEXT;

class kinlinehook {

public:
	kinlinehook() {}

	static BOOLEAN AutoHook(PVOID Dst, PVOID Src, PVOID *Proxy);
	static BOOLEAN Hook(HOOKPROC HookProc, PVOID Context);
	static VOID __stdcall DpcLock(struct _KDPC *Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2);

	static VOID WPOFF();
	static VOID WPON();
	

};

__forceinline
VOID kinlinehook::WPOFF()
{
	__asm {
		cli
		mov     eax, cr0
		and     eax, 0fffeffffh
		mov     cr0, eax
	}
}

__forceinline
VOID kinlinehook::WPON()
{
	__asm {
		mov     eax, cr0
		or      eax, 10000h
		mov     cr0, eax
		sti
	}
}

#endif